package com.cheer.enums;

/**
 * @author chufangzheng
 * 活动状态
 */
public enum ActivityStatusEnum {

    NOT_STARTED(1, "未开始"),
    IN_PROGRESS(2, "进行中"),
    COMPLETED(3, "已结束");


    private Integer code;
    private String message;

    ActivityStatusEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }


    /**
     * 检查状态是否在区间中
     * @return
     */
    public static ActivityStatusEnum getStatus(Long startSecond, Long endSecond){

        long currentSecond = System.currentTimeMillis() / 1000;
        if(currentSecond < startSecond){
            return ActivityStatusEnum.NOT_STARTED;
        }else if(currentSecond > startSecond && currentSecond < endSecond ){
            return ActivityStatusEnum.IN_PROGRESS;
        }else{
            return ActivityStatusEnum.COMPLETED;
        }
    }
}
